#include <set>
#include <map>
#include "BinanceRestApi.h"
#include "BinanceTrade.h"
#include "object.h"

int main(){
    std::string apiKey = "W1Z5h7RydJ8CNI40azIXOJKVudRLfawy3k8jEdbh0sfU74yHQzVr5a78IU2E2lRV";
    std::string secretKey = "ZMvkc39AOccvuxLnREzFPx7UZY11grocC08qO8R1lSe7L5yGyyZyq4WlwxF0u0gr";
    BinanceRestApi restApi(apiKey,secretKey);

    std::cout<<"test1=============================="<<std::endl;
    std::vector<std::string> symbols = restApi.getSymbolList();
    for(auto sym:symbols){
        std::cout<<sym<<" ";
    }
    std::cout<<std::endl;

    std::cout<<"test2=============================="<<std::endl;
    std::set<std::string> pairs;
    std::vector<std::string> coins;
    restApi.allTradingPairs(pairs,coins);
    std::cout<<"pairs:"<<pairs.size()<<std::endl;
    std::cout<<"coins:"<<coins.size()<<std::endl;

    std::cout<<"test3=============================="<<std::endl;
    std::string usdt = restApi.getSpotQuantity("USDT");
    std::cout<<"USDT:"<<usdt<<std::endl;

    std::cout<<"test4=============================="<<std::endl;
    std::map<std::string, double> symbol_info;
    restApi.getSymbolInfo(symbol_info);
    for(auto pair : symbol_info){
        std::cout << "Symbol: " << pair.first << ", MinQty: " << pair.second << std::endl;
    }

    std::cout<<"test5=============================="<<std::endl;
    std::map<std::string, double> coinBalance;
    restApi.getAccountBalance(coinBalance);
    for(auto pair:coinBalance){
        std::cout << "Symbol: " << pair.first << ", freeBalance: " << pair.second << std::endl;
    }
    std::cout << "coinBalance size: " << coinBalance.size() << std::endl;
    

    BinanceTrade *tradePtr = BinanceTrade::getInstance(apiKey,secretKey);
    std::cout<<"test6=============================="<<std::endl;
    std::thread trade(&BinanceTrade::connect,tradePtr);
    trade.join();

    return 0;
}